<template>
	<view class="container">
		<view class="big-box">
			<view class="box" v-for="(item,index) in list" @click="goDetails(item)">
				<image class="img" src="../../static/market/CGC.png" v-if="item.tradingType==1" mode=""></image>
				<image class="img" src="../../static/market/point.png" v-if="item.tradingType==0" mode=""></image>
				<view class="title">{{item.tradingTitle}}</view>
				<view class="number">
					<view class="left" v-if="item.tradingType==0">积分数量:{{item.tradingNum}}</view>
					<view class="left" v-if="item.tradingType==1">CGC数量:{{item.tradingNum}}</view>
					<view class="right">{{item.likeNum}}人想要</view>
				</view>
				<view class="price">
					<view class="left">￥{{item.tradingMoney}}</view>
					<view class="right">指导价￥{{item.referenceMoney}}</view>
				</view>
				<view class="user">
					<image :src="item.userImg" mode=""></image>
					<view class="username">{{item.userName}}</view>
				</view>
			</view>
		</view>
		<view class="noimg" v-if="list.length==0">
			<image src="../../static/noimg/nonews.png"></image>
		</view>
		<view class="push" @click="release">
			<image src="../../static/market/push.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	import {
		jylist
	} from "../../api/index.js"
	export default {
		data() {
			return {
				type: 0, //0:积分交易,1:cgc交易
				num: 1,
				list: []
			}
		},
		onShow() {
			this.list = []
			this.num = 1
			this.getlist()
		},
		onReachBottom() {
			this.getlist()
		},
		onPullDownRefresh() {
			this.list = []
			this.num = 1
			this.getlist()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
		},
		methods: {
			release() {
				uni.navigateTo({
					url: "publish/publish"
				})
			},
			async getlist() {
				let res = await this.get(jylist, {
					pageSize: 10,
					pageNum: this.num
				})
				this.list = [...this.list, ...res.data]
				this.num++

			},
			goDetails(item) {
				uni.navigateTo({
					url: 'details/details?item=' + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="less">
	.noimg {
		width: 750rpx;
		height: 70vh;
		display: flex;
		align-items: center;
		justify-content: center;

		image {
			width: 300rpx;
			height: 400rpx;
		}
	}

	.container {
		padding-bottom: 150rpx;
		box-sizing: border-box;
	}

	page {
		background: #F5F5F5;
	}

	.big-box {
		display: flex;
		flex-wrap: wrap;
	}

	.box {
		width: 330rpx;
		// height: 400rpx;
		background: #FFFFFF;
		border-radius: 12rpx;
		margin-left: 30rpx;
		margin-top: 30rpx;
		padding-bottom: 20rpx;

	}

	.title {
		padding: 0 20rpx;
		font-size: 24rpx;
		font-weight: bold;
		color: #333333;
	}

	.img {
		width: 148rpx;
		height: 148rpx;
		margin: 40rpx 91rpx;
	}

	.number {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;

		.left {
			font-size: 26rpx;
			font-weight: 300;
			color: #333333;
		}

		.right {
			font-size: 24rpx;
			font-weight: 400;
			color: #666666;
		}
	}

	.price {
		margin-top: 10rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;

		.left {
			font-size: 28rpx;
			font-weight: bold;
			color: #F09238;
		}

		.right {
			font-size: 24rpx;
			color: #999999;
		}
	}

	.user {
		display: flex;
		align-items: center;
		padding: 0 20rpx;
		margin-top: 10rpx;

		image {
			width: 32rpx;
			height: 32rpx;
			margin-right: 10rpx;
			border-radius: 50%;
		}

		.username {
			font-size: 24rpx;
			font-weight: bold;
			color: #333333;
		}
	}

	.push {
		width: 80rpx;
		height: 80rpx;
		position: fixed;
		bottom: 30rpx;
		left: 335rpx;

		image {
			width: 80rpx;
			height: 80rpx;
		}
	}
</style>
